import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.List;
import static java.lang.Thread.sleep;
public class Test {
    public static void main(String[] args) throws InterruptedException {
        Test01();
    }
    private static void Test01() throws InterruptedException {
        WebDriver webDriver = new ChromeDriver();
        webDriver.get("https://www.baidu.com");
        webDriver.manage().window().setSize(new Dimension(200,100));
        sleep(3000);
        WebElement webElement = webDriver.findElement(By.cssSelector("#kw"));
        if(webElement==null){
            System.out.println("测试不通过");
        }else{
            System.out.println("测试通过");
        }
    }

    public static void main2(String[] args) {
        WebDriver webDriver = new ChromeDriver();
        webDriver.get("https://www.b aidu.com");
        WebElement search_input = webDriver.findElement(By.cssSelector("#kw"));
        search_input.sendKeys("软件测试");
        WebElement baidu_button = webDriver.findElement(By.cssSelector("#su"));
        baidu_button.click();
        List<WebElement> search_results =  webDriver.findElements(By.cssSelector("a em"));
        for (int i = 0; i <search_results.size() ; i++) {
            if(search_results.get(i).getText().equals("软件测试")){
                System.out.println("测试通过");
            }else{
                System.out.println("测试不通过");
            }
        }
    }
    public static void main1(String[] args) {
        WebDriver webDriver = new ChromeDriver();
        webDriver.get("https://www.baidu.com");
        WebElement search_input = webDriver.findElement(By.cssSelector(".s_ipt"));
        if(search_input==null){
            System.out.println("测试不通过");
        }else{
            System.out.println("测试通过");
        }
        webDriver.quit();
    }
}